import jdk.internal.jline.internal.TestAccessible;
import mapper.OrderMapper;
import model.Order;
import org.apache.ibatis.session.*;

import javax.annotation.Resources;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.util.List;

public class OrderMapperTest {

    private OrderMapper mapper;

    @Before
    public void before() throws IOException {
        InputStream inputStream = Resources.gerResourceAsStream("SqlMapConig.xml");
        //获取SqlSessionFactory
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
        //获取SqlSession
        SqlSession sqlSession = sqlSessionFactory.openSession();
        mapper = sqlSession.getMapper(OrderMapper.class);
    }
    @Test
    public void selectOrderList(){
        List<Order> orders = mapper.selectOrderList();
        for (Order order : orders) {
            System.out.println(order);

        }

    }

}

